set(Boost_USE_STATIC_LIBS OFF) # only find static libs, default None
set(Boost_USE_MULTITHREADED ON) # default TRUE
set(Boost_USE_STATIC_RUNTIME OFF) # default None

find_package(Boost 1.69.0)
if (Boost_FOUND)
    option(BOOST_DISABLE_ASSERTS "add define BOOST_DISABLE_ASSERTS" OFF)
    include_directories(${Boost_INCLUDE_DIRS})
    add_executable(dm01_lexical_cast dm01_数值转换lexical_cast.cpp)
    add_executable(dm02_format dm02_格式化format.cpp)
    add_executable(dm03_string_algo1 dm03_字符串算法string_algo1.cpp)
    add_executable(dm04_string_algo2 dm04_字符串算法string_algo2.cpp)
    add_executable(dm05_string_algo3 dm05_字符串算法string_algo3.cpp)
    add_executable(dm06_BOOST_AUTO dm06_类型推导BOOST_AUTO和BOOST_TYPEOF.cpp)
    add_executable(dm07_tokenizer dm07_分词处理库tokenizer.cpp)
    add_executable(dm12_scoped_ptr dm12_智能指针scoped_ptr.cpp)
    add_executable(dm13_scoped_array dm13_智能数组指针scoped_array.cpp)
    add_executable(dm14_shared_ptr dm14_智能指针shared_ptr.cpp)
    add_executable(dm15_shared_ptr2 dm15_智能指针shared_ptr使用陷阱.cpp)
    add_executable(dm16_make_shared dm16_工厂函数make_shared.cpp)
    add_executable(dm17_shared_array dm17_智能数组指针shared_array.cpp)
    add_executable(dm18_weak_ptr dm18_弱引用智能指针weak_ptr.cpp)
    add_executable(dm19_weak_ptr2 dm19_weak_ptr的运用场景.cpp)
    add_executable(dm20_nocopyable dm20_禁止拷贝noncopyable.cpp)
    add_executable(dm21_timer1 dm21_计时器timer1.cpp)
    add_executable(dm23_ignore_unused dm23_ignore_unused.cpp)
    add_executable(dm24_optional dm24_optional.cpp)
    add_executable(dm25_tribool dm25_tribool.cpp)
    add_executable(dm26_uuid dm26_uuid.cpp)
    add_executable(dm27_assert dm27_assert.cpp)
    if (BOOST_DISABLE_ASSERTS)
        target_compile_definitions(dm27_assert PRIVATE -DBOOST_DISABLE_ASSERTS)
    endif ()
    add_executable(dm28_assert_handler dm28_assert_handler.cpp)
    add_executable(dm29_md5 dm29_md5.cpp)
endif ()

find_package(Boost 1.69.0 COMPONENTS date_time)
if (Boost_FOUND)
    add_executable(dm08_date_time1 dm08_日期时间库date_time1.cpp)
    target_link_libraries(dm08_date_time1 ${Boost_LIBRARIES})
    add_executable(dm09_date_time2 dm09_日期时间库date_time2.cpp)
    target_link_libraries(dm09_date_time2 ${Boost_LIBRARIES})
    add_executable(dm10_date_time3 dm10_日期时间库date_time3.cpp)
    target_link_libraries(dm10_date_time3 ${Boost_LIBRARIES})
    add_executable(dm11_date_time4 dm11_日期时间库date_time4.cpp)
    target_link_libraries(dm11_date_time4 ${Boost_LIBRARIES})
endif ()

find_package(Boost 1.69.0 COMPONENTS timer)
if (Boost_FOUND)
    add_executable(dm22_timer2 dm22_计时器timer2.cpp)
    target_link_libraries(dm22_timer2 ${Boost_LIBRARIES})
endif ()

find_package(Boost 1.69.0 COMPONENTS program_options)
if (Boost_FOUND)
    add_executable(dm30_program_options_1 dm30_命令行解析库program_options_1.cpp)
    target_link_libraries(dm30_program_options_1 ${Boost_LIBRARIES})
    add_executable(dm31_program_options_2 dm31_命令行解析库program_options_2.cpp)
    target_link_libraries(dm31_program_options_2 ${Boost_LIBRARIES})
endif ()
